var member_id = goods_id = '',ws = order_id = ''; 
document.addEventListener('plusready',function(){
	member_id = plus.storage.getItem('id');
	ws = plus.webview.currentWebview();
	goods_id = ws.goodsid;
	var store_id = ws.store_id;
//	console.log(apiRoot+"?act=goods&op=index&goods_id="+goodsid);
	plus.nativeUI.showWaiting('加载中...');
	$.ajax({ 
		type:"get", 
		url:apiRoot+"?act=goods&op=index&goods_id="+goods_id,
		dataType:'json', 
		success:function(data){ 
			if(data){ 
				$('.tel').attr('data-tel',data.goods_info.contacts_phone);
				$('.mui-media-body b').text(data.goods_info.goods_name);
				$('.mui-media-body p').eq(0).text(data.goods_info.goods_custom[1].value);
				$('.mui-media-body p').eq(1).text(data.goods_info.goods_custom[2].value);
				$('.school_type').text(data.goods_info.goods_custom[3].value); 
//				$('.school_type').text(data.goods_info.goods_price); 
				$('.mui-media-object').attr('src', (pics + data.goods_info.store_id + '/' + data.goods_info.goods_image));			//图片 
				$('.price b').text('￥'+data.goods_info.goods_price);			//价格
				$('.price s').text('市场价：'+data.goods_info.goods_marketprice);    //市场价
				$('.detail p').text(data.goods_info.goods_jingle);
				$('.mobile').html(data.goods_info.mobile_body); 
				$('.mobile img').css('margin-right','4px');
				$('.goumai').attr('data-goods_id',data.goods_info.goods_id);
				$('.goumai').attr('data-store_id',data.goods_info.store_id);
				
			}
			plus.nativeUI.closeWaiting();
			$(".goumai").unbind("click")
			$(".goumai").on("click",function(){
				var _this = $(this);
				var goods_id = _this.attr('data-goods_id');
				var store_id = _this.attr('data-store_id');
				var quantity = 1;
				if(!goods_id || !quantity){
					toast('缺少参数！');return;
				}
				var shuju = goods_id+'|'+quantity;
				var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
				var webviewContent= plus.webview.create('./Driving_goods.html','Driving_goods.html',{},{shuju:shuju,store_id:store_id,payment_type:'online',ifcart:0});//后台创建webview并打开show.html
				webviewContent.addEventListener("loaded", function() { //注册新webview的载入完成事件
			        nwaiting.close(); //新webview的载入完毕后关闭等待框
			        webviewContent.show("slide-in-right",500); //把新webview窗体显示出来，显示动画效果为速度200毫秒的右侧移入动画
				}, false);
//				openNewPage('goods.html')
			})
		}, 
		error:function(e){
			plus.nativeUI.closeWaiting();
			console.log(JSON.stringify(e));
			toast('连接失败！');
		}
	});
},false);